import request from '@/utils/request'

export function kc(id){
  return request({
    url: '/folder/getQR',
    method: 'get',
    params: {id}
  })
}
/**
 * 获取文件列表
 * @param id
 * @returns {AxiosPromise}
 */
export function getFolder(id) {
  return request({
    url: '/folder/getFolder/' + id,
    method: 'get'
  })
}

/**
 * 返回文件预览信息
 * @param id
 * @returns {AxiosPromise}
 */
export function getView(id){
  return request({
    url: '/file/getprview',
    method: 'get',
    params: {id}
  })
}
/**
 * 创建文件夹
 * @param data
 * @returns {AxiosPromise}
 */
export function createFolder(data) {
  return request({
    url: '/folder/create',
    method: 'post',
    data: data
  })
}

/**
 * 修改文件名
 * @param data
 * @returns {AxiosPromise}
 */
export function updateFolder(data){
  return request({
    url: '/folder/update',
    method: 'post',
    data: data
  })
}

/**
 * 移动文件夹
 * @param id
 * @param beforeId
 * @returns {AxiosPromise}
 */
export function removeFolder(id,beforeId){
  return request({
    url: '/folder/removeFolder',
    method: 'post',
    params:{
      'id': id, // 被移动文件id
      'beforeId': beforeId  // 目标文件id
    }
  })
}

/**
 * 文件上传
 * @param data
 * @returns {AxiosPromise}
 */
export function uploadFile(data){
  return request({
    url: '/file/uploadFile?pId=' + $store.state.file.breadCrumbs[this.$store.state.file.breadCrumbs.length - 1].id,
    method: 'post',
    data: data
  })
}

// 文件树状结构
export function getTree(){
  return request({
    url: '/folder/folderList',
    method: 'get',
  })
}

// 文件夹下载
export function download(path,id){
  return request({
    url: '/folder/download',
    method: 'get',
    params:{
      folderPath: path,
      id: id
    }
  })
}

// 单个文件下载
export function downloadOne(path,fileUrl){
  return request({
    url: '/folder/downloadOne',
    method: 'get',
    params: {
      path: path,
      fileUrl: fileUrl
    }
  })
}

// 备份盘移动至资源库
export function removeFolderTobfp(id){
  return request({
    url: '/folder/removeFolderToResource',
    method: 'post',
    params:{
      id: id
    }
  })
}

// 备份盘移动至回收站
export function removeFolderTohsz(id){
  return request({
    url: '/folder/removeFolderTohsz',
    method: 'post',
    params:{
      id: id,
    }
  })
}

// 收藏
export function collect(data){
  return request({
    url: '/folder/collect',
    method: 'post',
    data: data
  })
}
// 移动到密码箱
export function removetolocks(data){
  return request({
    url: '/box/removetod',
    method: 'post',
    data: data
  })
}
